package lu.med.praxiswahl.wahlumed.client.utilities;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.JButton;
import javax.swing.JTextArea;

@SuppressWarnings("serial")
public class FontChooserPanel extends JButton implements ActionListener {
	private Font choosenFont;
	private ArrayList<JTextArea> textArea = new ArrayList<JTextArea>();

	public FontChooserPanel() {
		super("Schriftart");
		this.addActionListener(this);
		setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/fonts.png")));

		choosenFont = new Font("Times New Roman", Font.PLAIN, 12);
	}

	public void actionPerformed(ActionEvent e) {

		FontDialog f = new FontDialog();

		Font x = f.showDialog();

		if (x != null) {
			if (textArea.size() != 0) {
				for (int i = 0; i < textArea.size(); i++) {
					this.textArea.get(i).setFont(x);
				}
			}
			this.choosenFont = x;
			x = null;
		}
	}

	public void addTextArea(JTextArea t) {
		textArea.add(t);
	}

	public Font getChoosenFont() {
		return choosenFont;
	}

	public void setChoosenFont(Font choosenFont) {
		this.choosenFont = choosenFont;
	}
}
